package cn.wizzer.app.web.modules.controllers.platform.user.chat.group;


import cn.wizzer.app.user.modules.services.GroupReportService;
import cn.wizzer.framework.util.Result;
import com.alibaba.dubbo.config.annotation.Reference;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

/**
 * 群举报
 *
 * @author .
 */
@IocBean
@At("/platform/user/group/report")
public class GroupReportController {

    @Inject
    @Reference
    private GroupReportService groupReportService;

    @At("/")
    @Ok("beetl:/platform/user/chat/group/report.html")
    @RequiresPermissions("user.group.report")
    public void index() {
    }


    /**
     * 查询（分页）
     *
     * @param groupName     群名
     * @param userKeyword   用户信息
     * @param searchDate    日期
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @At
    @Ok("json:full")
    @RequiresPermissions("user.group.report")
    public Object data(@Param("groupName") String groupName,
                       @Param("userKeyword") String userKeyword,
                       @Param("searchDate") String[] searchDate,
                       @Param("pageNumber") int pageNumber,
                       @Param("pageSize") int pageSize) {
        return Result.success().addData(groupReportService.listPage(pageNumber, pageSize, groupName, userKeyword, searchDate));
    }


    @At("/delete/?")
    @Ok("json:full")
    @RequiresPermissions("user.group.report.delete")
    public Object delete(String id) {
        groupReportService.delete(id);
        return Result.success();
    }
}
